from mitmproxy import http


class MockAPI:
    def request(self, flow: http.HTTPFlow):
        print("----------拦截请求---------")
        if flow.request.pretty_url == "https://www.cnblogs.com/yoyoketang":
            # 构造自定义 response
            flow.response = http.Response.make(200, "自定义返回内容",
                                               {"Content_Type:": "text/html"})


addons = [MockAPI()]
